<template>
  <div class="admin-dashboard">
    <!-- 侧边栏 -->
    <div class="sidebar">
      <div class="sidebar-header">
        <div class="admin-logo">
          <div class="admin-logo-icon">管</div>
          <div class="admin-logo-text">管理系统</div>
        </div>
      </div>
      
      <div class="sidebar-menu">
        <div 
          v-for="menu in menuList" 
          :key="menu.name"
          class="menu-item"
          :class="{ active: currentMenu === menu.name }"
          @click="handleMenuClick(menu)"
        >
          <div class="menu-icon">{{ menu.icon }}</div>
          <span>{{ menu.label }}</span>
        </div>
      </div>
      
      <div class="sidebar-footer">
        <div class="admin-avatar-container">
          <div class="admin-avatar">{{ adminInitial }}</div>
          <div class="admin-info">
            <div class="admin-name">{{ adminName }}</div>
            <div class="admin-role">超级管理员</div>
          </div>
        </div>
        
        <!-- 退出登录按钮 -->
        <div class="logout-btn" @click="handleLogout">
          <div class="logout-icon">🚪</div>
          <span>退出登录</span>
        </div>
      </div>
    </div>
    
    <!-- 主内容区域 -->
    <div class="main-content">
      <!-- 顶部导航 -->
      <div class="top-nav">
        <h1 class="page-title">
          <div class="page-title-icon">📈</div>
          数据统计
        </h1>
        
        <div class="top-actions">
          <!-- 时间范围选择 -->
          <el-radio-group v-model="timeRange" size="default" class="time-range-group" @change="handleTimeRangeChange">
            <el-radio-button label="TODAY">今天</el-radio-button>
            <el-radio-button label="WEEK">本周</el-radio-button>
            <el-radio-button label="MONTH">本月</el-radio-button>
            <el-radio-button label="YEAR">今年</el-radio-button>
          </el-radio-group>
          
          <el-button class="action-btn refresh-btn" @click="handleRefresh" :loading="loading">
            <span class="btn-icon">🔄</span>
            刷新数据
          </el-button>
          
          <el-button class="action-btn logout-btn" @click="handleLogout">
            <span class="btn-icon">🚪</span>
            退出登录
          </el-button>
        </div>
      </div>
      
      <!-- 统计卡片区域 -->
      <div class="stats-cards">
        <div 
          v-for="stat in overviewStats" 
          :key="stat.title"
          class="stat-card"
          :style="{ background: stat.gradient }"
          v-loading="loading"
        >
          <div class="stat-icon">{{ stat.icon }}</div>
          <div class="stat-content">
            <div class="stat-value">{{ stat.value }}</div>
            <div class="stat-title">{{ stat.title }}</div>
            <div class="stat-trend" :class="stat.trendClass">
              <span>{{ stat.trend }}</span>
              <span>{{ stat.trendText }}</span>
            </div>
          </div>
        </div>
      </div>
      
      <!-- 图表区域 -->
      <div class="charts-section">
        <!-- 订单趋势图 -->
        <div class="chart-card" v-loading="loading">
          <div class="chart-header">
            <h3>订单趋势</h3>
          </div>
          <div ref="orderTrendChartRef" class="chart-container"></div>
        </div>
        
        <!-- 销售趋势图 -->
        <div class="chart-card" v-loading="loading">
          <div class="chart-header">
            <h3>销售趋势</h3>
          </div>
          <div ref="salesTrendChartRef" class="chart-container"></div>
        </div>
      </div>
      
      <!-- 分类分布和商品排行 -->
      <div class="charts-section">
        <!-- 分类销售分布 -->
        <div class="chart-card" v-loading="loading">
          <div class="chart-header">
            <h3>分类销售分布</h3>
          </div>
          <div ref="categoryChartRef" class="chart-container"></div>
        </div>
        
        <!-- 商品销售排行表格 -->
        <div class="chart-card ranking-card" v-loading="loading">
          <div class="chart-header">
            <h3>商品销售排行 TOP 10</h3>
          </div>
          <div class="ranking-table">
            <div class="ranking-header">
              <div class="rank-col">排名</div>
              <div class="name-col">商品名称</div>
              <div class="sales-col">销量</div>
              <div class="amount-col">销售额</div>
            </div>
            <div 
              v-for="item in topProducts" 
              :key="item.productId"
              class="ranking-row"
            >
              <div class="rank-col">
                <div class="rank-badge" :class="'rank-' + item.ranking">
                  {{ item.ranking }}
                </div>
              </div>
              <div class="name-col">
                <div class="product-info">
                  <img v-if="item.productImage" :src="item.productImage" class="product-img" />
                  <div class="product-details">
                    <div class="product-name">{{ item.productName }}</div>
                    <div class="product-category">{{ item.categoryName }}</div>
                  </div>
                </div>
              </div>
              <div class="sales-col">{{ item.salesCount }}</div>
              <div class="amount-col">¥{{ formatAmount(item.salesAmount) }}</div>
            </div>
            
            <div v-if="topProducts.length === 0" class="empty-data">
              <div class="empty-icon">📊</div>
              <div class="empty-text">暂无数据</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, computed, watch, onUnmounted } from 'vue'
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/user'
import { ElMessage } from 'element-plus'
import * as echarts from 'echarts'
import {
  getOverviewStatistics,
  getOrderTrend,
  getSalesTrend,
  getCategoryDistribution,
  getTopProducts
} from '@/api/statistics'

const router = useRouter()
const userStore = useUserStore()

// 当前菜单
const currentMenu = ref('statistics')

// 时间范围
const timeRange = ref('WEEK')

// 加载状态
const loading = ref(false)

// 图表引用
const orderTrendChartRef = ref(null)
const salesTrendChartRef = ref(null)
const categoryChartRef = ref(null)

// 图表实例
let orderTrendChart = null
let salesTrendChart = null
let categoryChart = null

// 管理员信息
const adminName = computed(() => userStore.userInfo?.realName || '系统管理员')
const adminInitial = computed(() => adminName.value.charAt(0))

// 菜单列表
const menuList = [
  { name: 'dashboard', label: '数据看板', icon: '📊', path: '/admin/dashboard' },
  { name: 'employee', label: '员工管理', icon: '👥', path: '/admin/employee' },
  { name: 'card', label: '福利卡管理', icon: '🎁', path: '/admin/welfare-card' },
  { name: 'product', label: '商品管理', icon: '🛒', path: '/admin/product' },
  { name: 'order', label: '订单管理', icon: '📦', path: '/admin/order' },
  { name: 'statistics', label: '数据统计', icon: '📈', path: '/admin/statistics' }
]

// 概览统计数据
const overviewData = ref({
  totalOrders: 0,
  totalSalesAmount: 0,
  totalUsers: 0,
  cardExchangeRate: 0,
  orderGrowthRate: 0,
  salesGrowthRate: 0,
  userGrowthRate: 0
})

// 订单趋势数据
const orderTrendData = ref([])

// 销售趋势数据
const salesTrendData = ref([])

// 分类分布数据
const categoryData = ref([])

// 商品排行数据
const topProducts = ref([])

// 概览统计卡片
const overviewStats = computed(() => [
  {
    icon: '📦',
    title: '订单总数',
    value: overviewData.value.totalOrders || 0,
    trend: formatTrend(overviewData.value.orderGrowthRate),
    trendText: '环比',
    trendClass: getTrendClass(overviewData.value.orderGrowthRate),
    gradient: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)'
  },
  {
    icon: '💰',
    title: '销售总额',
    value: `¥${formatAmount(overviewData.value.totalSalesAmount)}`,
    trend: formatTrend(overviewData.value.salesGrowthRate),
    trendText: '环比',
    trendClass: getTrendClass(overviewData.value.salesGrowthRate),
    gradient: 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)'
  },
  {
    icon: '👥',
    title: '新增用户',
    value: overviewData.value.totalUsers || 0,
    trend: formatTrend(overviewData.value.userGrowthRate),
    trendText: '环比',
    trendClass: getTrendClass(overviewData.value.userGrowthRate),
    gradient: 'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)'
  },
  {
    icon: '🎁',
    title: '额度卡兑换率',
    value: `${overviewData.value.cardExchangeRate || 0}%`,
    trend: '',
    trendText: '总体',
    trendClass: '',
    gradient: 'linear-gradient(135deg, #fa709a 0%, #fee140 100%)'
  }
])

// 格式化金额
function formatAmount(amount) {
  if (!amount) return '0.00'
  return Number(amount).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
}

// 格式化趋势
function formatTrend(rate) {
  if (!rate || rate === 0) return ''
  const value = Math.abs(rate)
  return rate > 0 ? `↑ ${value}%` : `↓ ${value}%`
}

// 获取趋势样式类
function getTrendClass(rate) {
  if (!rate || rate === 0) return ''
  return rate > 0 ? 'trend-up' : 'trend-down'
}

// 加载概览数据
async function loadOverviewData() {
  try {
    const res = await getOverviewStatistics(timeRange.value)
    if (res.code === 200) {
      overviewData.value = res.data
    }
  } catch (error) {
    console.error('加载概览数据失败:', error)
  }
}

// 加载订单趋势数据
async function loadOrderTrendData() {
  try {
    const res = await getOrderTrend(timeRange.value)
    if (res.code === 200) {
      orderTrendData.value = res.data
      renderOrderTrendChart()
    }
  } catch (error) {
    console.error('加载订单趋势数据失败:', error)
  }
}

// 加载销售趋势数据
async function loadSalesTrendData() {
  try {
    const res = await getSalesTrend(timeRange.value)
    if (res.code === 200) {
      salesTrendData.value = res.data
      renderSalesTrendChart()
    }
  } catch (error) {
    console.error('加载销售趋势数据失败:', error)
  }
}

// 加载分类分布数据
async function loadCategoryData() {
  try {
    const res = await getCategoryDistribution(timeRange.value)
    if (res.code === 200) {
      categoryData.value = res.data
      renderCategoryChart()
    }
  } catch (error) {
    console.error('加载分类分布数据失败:', error)
  }
}

// 加载商品排行数据
async function loadTopProductsData() {
  try {
    const res = await getTopProducts(timeRange.value, 10)
    if (res.code === 200) {
      topProducts.value = res.data
    }
  } catch (error) {
    console.error('加载商品排行数据失败:', error)
  }
}

// 加载所有数据
async function loadAllData() {
  loading.value = true
  try {
    await Promise.all([
      loadOverviewData(),
      loadOrderTrendData(),
      loadSalesTrendData(),
      loadCategoryData(),
      loadTopProductsData()
    ])
  } catch (error) {
    ElMessage.error('加载数据失败')
  } finally {
    loading.value = false
  }
}

// 渲染订单趋势图
function renderOrderTrendChart() {
  if (!orderTrendChartRef.value) return
  
  if (!orderTrendChart) {
    orderTrendChart = echarts.init(orderTrendChartRef.value)
  }
  
  const dates = orderTrendData.value.map(item => item.date)
  const counts = orderTrendData.value.map(item => item.orderCount)
  
  const option = {
    tooltip: {
      trigger: 'axis',
      backgroundColor: 'rgba(50, 50, 50, 0.9)',
      borderColor: '#333',
      textStyle: { color: '#fff' }
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      top: '10%',
      containLabel: true
    },
    xAxis: {
      type: 'category',
      data: dates,
      axisLine: { lineStyle: { color: '#ddd' } },
      axisLabel: { color: '#666' }
    },
    yAxis: {
      type: 'value',
      axisLine: { lineStyle: { color: '#ddd' } },
      axisLabel: { color: '#666' },
      splitLine: { lineStyle: { color: '#f0f0f0' } }
    },
    series: [
      {
        name: '订单数量',
        type: 'line',
        smooth: true,
        data: counts,
        itemStyle: { color: '#667eea' },
        areaStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            { offset: 0, color: 'rgba(102, 126, 234, 0.5)' },
            { offset: 1, color: 'rgba(102, 126, 234, 0.05)' }
          ])
        }
      }
    ]
  }
  
  orderTrendChart.setOption(option)
}

// 渲染销售趋势图
function renderSalesTrendChart() {
  if (!salesTrendChartRef.value) return
  
  if (!salesTrendChart) {
    salesTrendChart = echarts.init(salesTrendChartRef.value)
  }
  
  const dates = salesTrendData.value.map(item => item.date)
  const amounts = salesTrendData.value.map(item => item.salesAmount)
  
  const option = {
    tooltip: {
      trigger: 'axis',
      backgroundColor: 'rgba(50, 50, 50, 0.9)',
      borderColor: '#333',
      textStyle: { color: '#fff' },
      formatter: (params) => {
        const value = params[0].value
        return `${params[0].name}<br/>销售额: ¥${formatAmount(value)}`
      }
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      top: '10%',
      containLabel: true
    },
    xAxis: {
      type: 'category',
      data: dates,
      axisLine: { lineStyle: { color: '#ddd' } },
      axisLabel: { color: '#666' }
    },
    yAxis: {
      type: 'value',
      axisLine: { lineStyle: { color: '#ddd' } },
      axisLabel: { 
        color: '#666',
        formatter: (value) => '¥' + (value / 1000).toFixed(1) + 'k'
      },
      splitLine: { lineStyle: { color: '#f0f0f0' } }
    },
    series: [
      {
        name: '销售额',
        type: 'bar',
        data: amounts,
        itemStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            { offset: 0, color: '#f093fb' },
            { offset: 1, color: '#f5576c' }
          ])
        },
        barWidth: '40%'
      }
    ]
  }
  
  salesTrendChart.setOption(option)
}

// 渲染分类分布图
function renderCategoryChart() {
  if (!categoryChartRef.value) return
  
  if (!categoryChart) {
    categoryChart = echarts.init(categoryChartRef.value)
  }
  
  const data = categoryData.value.map(item => ({
    name: item.categoryName,
    value: item.salesAmount
  }))
  
  const option = {
    tooltip: {
      trigger: 'item',
      backgroundColor: 'rgba(50, 50, 50, 0.9)',
      borderColor: '#333',
      textStyle: { color: '#fff' },
      formatter: (params) => {
        return `${params.name}<br/>销售额: ¥${formatAmount(params.value)}<br/>占比: ${params.percent}%`
      }
    },
    legend: {
      orient: 'vertical',
      right: '10%',
      top: 'center',
      textStyle: { color: '#666' }
    },
    series: [
      {
        name: '分类销售',
        type: 'pie',
        radius: ['40%', '70%'],
        center: ['40%', '50%'],
        avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 10,
          borderColor: '#fff',
          borderWidth: 2
        },
        label: {
          show: true,
          formatter: '{b}: {d}%'
        },
        emphasis: {
          label: {
            show: true,
            fontSize: 16,
            fontWeight: 'bold'
          }
        },
        data: data
      }
    ]
  }
  
  categoryChart.setOption(option)
}

// 时间范围变化
function handleTimeRangeChange() {
  loadAllData()
}

// 刷新数据
function handleRefresh() {
  loadAllData()
}

// 菜单点击
function handleMenuClick(menu) {
  if (menu.path) {
    router.push(menu.path)
  }
}

// 退出登录
function handleLogout() {
  userStore.logout()
  router.push('/login')
  ElMessage.success('已退出登录')
}

// 监听窗口大小变化
function handleResize() {
  orderTrendChart?.resize()
  salesTrendChart?.resize()
  categoryChart?.resize()
}

// 挂载后初始化
onMounted(() => {
  loadAllData()
  window.addEventListener('resize', handleResize)
})

// 卸载前清理
onUnmounted(() => {
  window.removeEventListener('resize', handleResize)
  orderTrendChart?.dispose()
  salesTrendChart?.dispose()
  categoryChart?.dispose()
})
</script>

<style scoped lang="scss">
.admin-dashboard {
  display: flex;
  height: 100vh;
  background: #f5f7fa;
}

// 侧边栏样式
.sidebar {
  width: 220px;
  background-color: white;
  height: 100vh;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #f0f0f0;
}

.admin-logo {
  display: flex;
  align-items: center;
}

.admin-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #f56c6c 0%, #f78989 100%);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 10px;
  color: white;
  font-weight: bold;
  font-size: 18px;
}

.admin-logo-text {
  font-size: 18px;
  font-weight: 600;
  color: #f56c6c;
}

.sidebar-menu {
  flex: 1;
  padding: 20px 0;
  overflow-y: auto;
}

.menu-item {
  padding: 12px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.3s;
  
  &:hover {
    background-color: #f5f7fa;
  }
  
  &.active {
    background-color: #fef0f0;
    color: #f56c6c;
    border-right: 3px solid #f56c6c;
  }
}

.menu-icon {
  margin-right: 10px;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 15px 20px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-avatar-container {
  display: flex;
  align-items: center;
  width: 100%;
}

.admin-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #f56c6c;
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-weight: bold;
  margin-right: 10px;
}

.admin-info {
  flex: 1;
}

.admin-name {
  font-weight: 500;
  font-size: 14px;
}

.admin-role {
  color: #909399;
  font-size: 12px;
}

.logout-btn {
  width: 100%;
  background: linear-gradient(135deg, #ef5350 0%, #e53935 100%);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(239, 83, 80, 0.3);
  
  &:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(239, 83, 80, 0.4);
  }
}

.logout-icon {
  font-size: 14px;
}

// 主内容区域
.main-content {
  flex: 1;
  margin-left: 220px;
  padding: 20px;
}

.top-nav {
  background-color: white;
  border-radius: 12px;
  padding: 15px 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.page-title {
  font-size: 22px;
  font-weight: 600;
  display: flex;
  align-items: center;
  margin: 0;
}

.page-title-icon {
  width: 32px;
  height: 32px;
  background-color: #f56c6c;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 10px;
  color: white;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.time-range-group {
  margin-right: 12px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.3s;
  
  &.refresh-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    
    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    }
  }
  
  &.logout-btn {
    background: #f5f7fa;
    color: #666;
    border: 1px solid #e4e7ed;
    
    &:hover {
      background: #fff;
      border-color: #667eea;
      color: #667eea;
    }
  }
}

.btn-icon {
  font-size: 16px;
}

// 统计卡片
.stats-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 20px;
  color: white;
  transition: all 0.3s;
  
  &:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  }
}

.stat-icon {
  font-size: 48px;
  opacity: 0.9;
}

.stat-content {
  flex: 1;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.stat-title {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 8px;
}

.stat-trend {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
  
  &.trend-up {
    color: rgba(255, 255, 255, 0.95);
  }
  
  &.trend-down {
    color: rgba(255, 255, 255, 0.8);
  }
}

// 图表区域
.charts-section {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.chart-card {
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  
  &.ranking-card {
    overflow: hidden;
  }
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  
  h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0;
  }
}

.chart-container {
  width: 100%;
  height: 350px;
}

// 排行榜样式
.ranking-table {
  max-height: 500px;
  overflow-y: auto;
}

.ranking-header {
  display: grid;
  grid-template-columns: 80px 1fr 100px 120px;
  padding: 12px 16px;
  background: #f5f7fa;
  border-radius: 8px;
  font-weight: 600;
  color: #666;
  font-size: 14px;
  margin-bottom: 8px;
}

.ranking-row {
  display: grid;
  grid-template-columns: 80px 1fr 100px 120px;
  padding: 16px;
  border-bottom: 1px solid #f0f0f0;
  align-items: center;
  transition: all 0.3s;
  
  &:hover {
    background: #f9fafb;
  }
  
  &:last-child {
    border-bottom: none;
  }
}

.rank-col {
  text-align: center;
}

.rank-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  color: white;
  background: #95a5a6;
  
  &.rank-1 {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 2px 8px rgba(240, 147, 251, 0.4);
  }
  
  &.rank-2 {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 2px 8px rgba(79, 172, 254, 0.4);
  }
  
  &.rank-3 {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    box-shadow: 0 2px 8px rgba(250, 112, 154, 0.4);
  }
}

.name-col {
  padding: 0 16px;
}

.product-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.product-img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid #e4e7ed;
}

.product-details {
  flex: 1;
}

.product-name {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a2e;
  margin-bottom: 4px;
}

.product-category {
  font-size: 12px;
  color: #999;
}

.sales-col,
.amount-col {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a2e;
  text-align: right;
  padding-right: 16px;
}

.empty-data {
  padding: 60px 20px;
  text-align: center;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-text {
  font-size: 14px;
  color: #999;
}

// 响应式设计
@media (max-width: 1400px) {
  .stats-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .stats-cards {
    grid-template-columns: 1fr;
  }
  
  .charts-section {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    display: none;
  }
}
</style>

